/*
** client.c for client zappy in /home/hubert_s//zappouet/client
** 
** Made by sevan hubert
** Login   <hubert_s@epitech.net>
** 
** Started on  Sun Jun 26 15:06:55 2011 sevan hubert
** Last update Tue Jun 28 14:42:38 2011 sevan hubert
*/

#include <stdlib.h>

#include "client_zappy.h"

inventaire	*init_inventaire()
{
  inventaire	*sac;

  sac = (inventaire*)xmalloc(sizeof(drone));
  sac->nourriture = 0;
  sac->linemate = 0;
  sac->deraumere = 0;
  sac->sibur = 0;
  sac->mendiane = 0;
  sac->phiras = 0;
  sac->thystame = 0;
  return (sac);
}

t_list	*init_actions()
{
  t_list	*actions;
  item		*act;

  actions = alloc_list();
  act = alloc_list_item();
  init_list(actions);
  init_list_item(act, &voir, sizeof(&voir));
  put_begin_list(actions, act);
  act = alloc_list_item();
  init_list_item(act, &move, sizeof(&voir));
  put_end_list(actions, act);
  return (actions);
}

drone   *init_drone()
{
  drone	*this;
  
  this = (drone*)xmalloc(sizeof(drone));
  this->lvl = 1;
  this->vision = NULL;
  this->sac = init_inventaire();
  this->actions = NULL;
  return (this);
}

int	do_priority(drone *this)
{
  return (KO);
}

int	do_actions(drone *this)
{
  int	(*action)(drone*);
  item	*to_delete;

  to_delete = this->actions->begin;
  action = this->actions->begin->object;
  action(this);
  remove_item_in_list(this->actions, to_delete);
  free(to_delete);
  if (this->actions->is_empty)
    {
      free(this->actions);
      this->actions = NULL;
    }
  return (OK);
}

int	main()
{
  drone	*this;

  this = init_drone();
  while (42)
    {
      if (!do_priority(this))
	{
	  if (this->actions == NULL)
	    this->actions = init_actions();
	  do_actions(this);
	}
    }
}
